<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script>
	var tables = $('#dataTables').DataTable({
		"sAjaxSource" : '{{ urlfor "AcceptanceController.Index"}}'
		,"bLengthChange": false
		,"fnServerData" : function(sSource, aoData, fnCallback) {
			var params = checkQueryTableData(aoData);
			$('#search_key').val() ? params.entry_number = $('#search_key').val() : '';
			$.post(sSource, JSON.stringify(params),function(resp) {
				fnCallback(resp);
			},'json')
		}
		,columns: [
			{"bSortable": false, render:function(data, type, full, meta) {
				return full.Entry.Number;
			}}
			,{"bSortable": false, render:function(data, type, full, meta) {
			    if(!full.Entry.Suppliers) {
			        return '';
                }
				return '<a href="javascript:;" data-am-popover="{content: \''+ full.Entry.Suppliers.Name +'<br />联系人：'+ full.Entry.Suppliers.Contacts +'<br />电话：'+ full.Entry.Suppliers.Tel +'\', trigger: \'hover focus\'}">'+ full.Entry.Suppliers.Name +'</a>';
				
			}}
			,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Entry.CreatedBy;
             }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return timetransDate(full.Entry.CreatedAt);
             }}
			,{"data" : "Number", "bSortable": false}
            ,{"data" : "AcceptanceUser", "bSortable": false}
			,{"data" : "AcceptanceDate", "bSortable": false, render:function(data, type, full, meta) {
				return timetransDate(data);
			}}
            ,{"data" : "AcceptanceNum", "bSortable": false}
			,{   
				"mDataProp": "Action", 
				"bSortable": false, 
				"sWidth":"10%",
				"render": function ( data, type, full, meta ) { 
					btns = '';
                    btns += '<a class="am-btn am-btn-secondary am-btn-xs" href="javascript:;" onclick="showDetails('+ full.Id +');return false;">收货验收商品清单</a>';
					return btns;
				}  
			 } 
		]
		,"aLengthMenu":[20, 50, 100, 200]
		,"serverSide": true
		,"bPaginate" : true
		,"bFilter" : false	//是否启动过滤、搜索功能 
		,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
		,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示 
		,'bLengthChange': true		
		,"drawCallback": function(settings){
			$('[data-am-popover]').popover();
		}   
	});
	
	$("#searchsubmit").bind("click", function () { //点击按钮 触发table重新请求服务器
		$("#dataTables").dataTable().fnDraw(false);
	});

	function dialogReback() {
		tables.ajax.reload();
	}

    function showDetails(id){
        var url = '{{urlfor "AcceptanceController.Details"}}/'+id;
        layer.open({
            type: 2,
            title: "收货验收商品清单",
            shadeClose: false,
            shade: 0.2,
            maxmin: true,
            shift: 1,
            area: ['85%', '80%'],
            content: url
        });
        return false;
    }

</script>